var QS_Forex_CRT_Push_Plugin=function(cfg){
	this.cfg = $.extend({exchangeId:245,tickerPostfix:"FLIT"},cfg)
    this.tValidation = null;
    this.monitor="BidPrice";
	this.rate="spot";
	this.key="";
    this.callback={updateData:function(){}};
	this.init();
};
QS_Forex_CRT_Push_Plugin.prototype = {
	init:function(){
		this._getKey();
	},
    subscribeSymbols:function(gKeyList){
        if(gKeyList==null||gKeyList.length==0){
            return;
        }
        this.tValidation.checkTickers(gKeyList);
    },
	unSubscribe:function(tickers,flag){
		this.tValidation.unSubscribe(tickers,flag);
	},
    parseCfg:function(cfg){
        if (cfg.monitor) {
            if (cfg.monitor == "askprice") {
                cfg.monitor = "AskPrice"
            }
            if (cfg.monitor == "bidprice") {
                cfg.monitor = "BidPrice"
            }
            this.monitor = cfg.monitor;
        }
		if(cfg.rate){
           this.rate = cfg.rate;
        }
		this._getKey();
    },
	_getKey:function(){
		if(this.rate=="spot"){
            this.key = this.monitor;
        }else{
            if(this.monitor=="AskPrice"){
                this.key = parseInt(this.rate);
            }else{
                this.key = parseInt(this.rate)+1;
            }
        }
	},
    getSubscribeKey:function(x,y){
        return this.cfg.exchangeId + ":"  + x + y+ this.cfg.tickerPostfix;
    },
    setTickerValidation:function(tv){
        this.tValidation=tv;
    },
    updateDataFromGData:function(gKey,data){
        if(!data){
            return false;
        }  
        var cp = data[this.key];
        if(cp){
            this.callback.updateData(gKey,cp,data["Chg%"]);
        }
    },
    getCfg:function(){
        return {monitor:this.monitor,rate:this.rate};
    },
    updateData:function(gKey,data){
        if(!data){
            return false;
        }  
        var cp = data[this.key];
        if(cp){
            this.callback.updateData(gKey,cp["value"],gData[gKey]["Chg%"]);
        }
     }
};